import sys
import pylab as plt
import os
from params import *

file = os.path.join(WORKDIR, 'gowalla', 'temporal', "geogap_params.txt")

degrees = []
pzeros = []
averages = []
g_averages = []
stds = []
alphas = []
threshold = []
meds = []
for line in open(file):
    #d,pzero,avg,geom_avg,std,K,th,alpha = map(float,line.strip().split())
    d,alpha,th, avg, std, med = map(float,line.strip().split())
    degrees.append(d)
    #pzeros.append(pzero)
    averages.append(avg)
    #g_averages.append(geom_avg)
    #stds.append(std)
    threshold.append(th)
    alphas.append(alpha)
    meds.append(med)

#plt.figure()
#plt.clf()
#plt.axes(FIG_AXES2)
#plt.plot(degrees,pzeros,'k.')#,mfc='None')
#plt.xlabel('Current degree')
#plt.ylabel(r'$P_{geo}(0)$')
#plt.grid(True)
#plt.savefig('geogap_pzero.pdf')
#plt.close()

plt.figure()
plt.clf()
plt.axes(FIG_AXES2)
plt.plot(degrees,averages,'ko',mfc='None')
plt.plot(degrees,meds,'ks',mfc='None')
plt.xlabel(r'$k$')
plt.ylabel(r'$\langle \lambda(k) \rangle$')
plt.ylabel('Link distance [km]')
plt.legend(['Average', 'Median'],numpoints=1, loc='upper left')
plt.grid(True)
plt.savefig('geogap_avg.pdf')
plt.close()

#plt.figure()
#plt.clf()
#plt.axes(FIG_AXES2)
#plt.plot(degrees,stds,'k.')#,mfc='None')
#plt.xlabel(r'$k$')
#plt.ylabel(r'$\sigma(\lambda(k))$')
#plt.grid(True)
#plt.savefig('geogap_std.pdf')
#plt.close()

#plt.figure()
#plt.clf()
#plt.axes(FIG_AXES2)
#plt.plot(degrees,g_averages,'k.')#,mfc='None')
#plt.xlabel(r'$k$')
#plt.ylabel(r'$\langle \lambda(k) \rangle_G$')
#plt.grid(True)
#plt.savefig('geogap_geomavg.pdf')
#plt.close()

#plt.figure()
#plt.clf()
#plt.axes(FIG_AXES2)
#plt.plot(degrees,alphas,'ko',mfc='None')
#plt.xlabel(r'$k$')
#plt.ylabel(r'$\alpha_k$')
#plt.grid(True)
#plt.savefig('geogap_alpha.pdf')
#plt.close()
#
#plt.figure()
#plt.clf()
#plt.axes(FIG_AXES2)
#plt.plot(degrees,threshold,'ko',mfc='None')
#plt.xlabel(r'$k$')
#plt.ylabel(r'$\theta_k$')
#plt.grid(True)
#plt.savefig('geogap_x0.pdf')
#plt.close()
